﻿#include "musiclist.h"
#include <QMimeDatabase>

MusicList::MusicList()
{

}

void MusicList::addMusicByUrls(const QList<QUrl>& musicUrls) {
	for (auto e : musicUrls) {
		QMimeDatabase mimeDB;
		QMimeType mimeType = mimeDB.mimeTypeForName(e.toLocalFile());
		QString name = mimeType.name();

		//过滤MIME类型，audio/mepg:mp3 audio/flac:无损音乐 audio/wav
		if (name == "audio/mepg" || name == "audio/flac" || name == "audio/wav") {
			//解析每个音乐的信息，并存起来audio/wav
			Music music(e);
			musicList.push_back(music);
		}
	}
}
